// pinia 的异步写法

import {defineStore} from "pinia";
import {ref} from "vue";
import axios from "axios";

export const useChannelStore = defineStore('channel', () => {
    const channelList = ref([]);
    const getList = async () => {
        // 支持异步
        // 正常写法即可
        const {data: {data}} = await axios.get('http://geek.itheima.net/v1_0/channels');
        channelList.value = data.channels
        console.log(data.channels)
    }

    return {
        channelList,
        getList
    }
});